<?php
namespace app\mxty\model;

use think\Model;
use think\model\concern\SoftDelete;

class ArenaPart extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $table = 'athlon_arena_part';
    protected $pk = 'arena_part_id';

    public function fragments()
    {
        return $this->belongsToMany(
            TimeFragment::class,
            ArenaPartTimeFragment::class
        );
    }

    public function bookings()
    {
        return $this->hasManyThrough(
            Booking::class,
            ArenaPartTimeFragment::class
        );
    }

    public function arena()
    {
        return $this->belongsTo(Arena::class);
    }

    // 关联该半场下的所有场次
    public function sessions()
    {
        return $this->hasMany(ArenaPartTimeFragment::class);
    }

}
